using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Rocuna.Core.Exceptions;
using Rocuna.GameEngine.Graphics;
using Rocuna.GameEngine.State;
using Rocuna.GameEngine.State.Screens;
using Rocuna.GameEngine.Extension;

namespace POCGame.Screens
{
    public class LoadingScreen : SplashScreen
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="SplashScreen"/> class.
        /// </summary>
        /// <param name="game"></param>
        public LoadingScreen(Game game)
            : base(game.Content.Load<Texture2D>("load"), game)
        {
        }

        protected override void LoadAllContent()
        {
            var screenManager = Game.GetService<ScreenManager>();
            var level1 = screenManager.GetScreen<Level1>();
            if (level1 == null)
                throw new Exception("Level1 is not registerd in screen manager");
            level1.Initialize();
            screenManager.ActivateScreen("Level1");
        }
    }
}